//
//  CJBaseTableViewCell.m
//  DatangLife
//
//  Created by 娜 on 2018/4/19.
//  Copyright © 2018年 DatangLife. All rights reserved.
//

#import "CJBaseTableViewCell.h"

@implementation CJBaseTableViewCell

- (UITableView *)tableView{
    float version = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (version >= 7.0) {
        return (UITableView *)self.superview.superview;
    }else{
        return (UITableView *)self.superview;
    }
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}




+ (instancetype)cellWithTableView:(UITableView *)tableView{
    if (tableView == nil) {
        return [[self alloc] init];
    }
    NSString *className = NSStringFromClass([self class]);
    NSString *identifier = [className stringByAppendingString:@"CellID"];
    [tableView registerClass:[self class] forCellReuseIdentifier:identifier];
    return [tableView dequeueReusableCellWithIdentifier:identifier];
}

+ (instancetype)nibWithTableView:(UITableView *)tableView{
    if (tableView == nil) {

        return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    }
    NSString *className = NSStringFromClass([self class]);
    NSString *identtifier = [className stringByAppendingString:@"nibCellID"];
    UINib *nib = [UINib nibWithNibName:className bundle:nil];

    [tableView registerNib:nib forCellReuseIdentifier:identtifier];
    return [tableView dequeueReusableCellWithIdentifier:identtifier];
}

@end
